#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75758-vfat.sh
# Version:    1.0
# Date:       2013/11/26
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    04系统兼容性-01文件系统兼容性-05vfat-01格式化并挂载vfat文件系统分区
# Notes:       vfat文件系统
# Copyright:   China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/11/26
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ./lib/cmd.sh
source ../../lib/XmlParse.sh
source ./lib/Partition_fdisk.sh

function CleanData ()
{
  EchoInfo "卸载分区"
  umount /dir1
  rm -rf /dir1
  EchoInfo "删除分区"
  DeletePartition
  partprobe
  rm -rf /tmp/tmp1
  rm -rf /tmp/tmp2
  EchoInfo "75758-vfat.sh执行完毕"
}

trap "CleanData" EXIT

#Create a partition

CreatePartition
partprobe
# 格式化vfat分区
Partition=`fdisk -l |tail -1 |cut -d " " -f1`
mkfs.vfat ${Partition}
EchoResult "格式化vfat文件系统分区成功" 

sleep 5

#挂载vfat分区到本地目录
mkdir /dir1
mount -o utf8 ${Partition} /dir1
mount |grep ${Partition}
EchoResult "成功挂载vfat分区到本地目录"

